# Sample clustering with traits

library(WGCNA)

args <- commandArgs(trailingOnly = TRUE)

print(args)

exprFilePath = "/Users/zyl/Workspace/hzau/MOIN-Extension-Github/WGCNA-Extension/FemaleLiver-Data/datExpr.csv"
traitFilePath = "/Users/zyl/Workspace/hzau/MOIN-Extension-Github/WGCNA-Extension/FemaleLiver-Data/datTraits.csv"

datExpr = read.csv(exprFilePath, stringsAsFactors = FALSE, row.names = 1);
datTraits = read.csv(traitFilePath, stringsAsFactors = FALSE, row.names = 1);

sampleTree = hclust(dist(datExpr), method = "average");
traitColors = numbers2colors(datTraits, signed = FALSE);

sample_num = nrow(datExpr)

png(
  filename = "/Users/zyl/Workspace/hzau/MOIN-Extension-Github/WGCNA-Extension/FemaleLiver-Data/cluster2.png",
  width = ceiling(sample_num/6),
  height = 9,
  units = "in",
  res = 300
)

plotDendroAndColors(sampleTree, traitColors,
                    groupLabels = names(datTraits),
                    main = "Sample dendrogram and trait heatmap")

dev.off()
